package com.voiceblog.action;

import java.util.Date;
import java.util.List;

import com.voiceblog.model.Users;

public class Login extends BaseAction {
	private String loginAccount;
	private String password;
	private Users blogUser;
	private List user;
	
	

	public String login() throws Exception {
		user =  getDao().findByUser(loginAccount, password);
		
		if(!user.isEmpty()){
			
		   blogUser = getDao().findById(loginAccount);
		   blogUser.setLastLoginTime(new Date());
			getSession().put("blogUser", blogUser);
			return SUCCESS;
		} else {
			return ERROR;
		}
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Users getBlogUser() {
		return blogUser;
	}

	public void setBlogUser(Users blogUser) {
		this.blogUser = blogUser;
	}

	public String getLoginAccount() {
		return loginAccount;
	}

	public void setLoginAccount(String loginAccount) {
		this.loginAccount = loginAccount;
	}

	public List getUser() {
		return user;
	}

	public void setUser(List user) {
		this.user = user;
	}



}
